package com.acwing.chapter3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author anan
 * @create 2021-07-27 21:51
 */
public class Shuzuyuansu800 {
    public static void main(String[] args) throws IOException {
        int N = 100010;
        int[] A = new int[N];
        int[] B = new int[N];
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] str1 = reader.readLine().split(" ");
        int n = Integer.parseInt(str1[0]);
        int m = Integer.parseInt(str1[1]);
        int x = Integer.parseInt(str1[2]);

        String[] str2 = reader.readLine().split(" ");
        String[] str3 = reader.readLine().split(" ");

        for (int i = 0; i < n; i++) {
            A[i] = Integer.parseInt(str2[i]);
        }

        for (int i = 0; i < m; i++) {
            B[i] = Integer.parseInt(str3[i]);
        }

        for (int i = 0, j = m - 1; i < n; i++) {
            while (A[i] + B[j] > x) j--;
            if (A[i] + B[j] == x){
                System.out.println(i + " " + j);
                return;
            }

        }




    }
}
